<%@ page import="org.internna.iwebjtracker.spring.mvc.IssueController" %>
<%@ taglib prefix="iwebmvc" uri="http://tags.iwebmvc.com" %>
<%@ taglib prefix="iwebjtracker" tagdir="/WEB-INF/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c-rt:set var="issue" value="<%= IssueController.ISSUE %>" />
<c-rt:set var="sessionUser" value="<%= org.internna.iwebmvc.security.UserManager.SESSION_USER %>" />
<iwebmvc:panel collapsible="false" title="${requestScope[issue].alias}: ${requestScope[issue].summary}" cssStyle="text-align:left;margin-bottom:3px" open="false"></iwebmvc:panel>
<div id="${fn:replace(requestScope[issue].alias, "-", "_")}Control" dojoType="dijit.layout.TabContainer" style="width:100%;height:310px;overflow:hidden;" tabPosition="bottom" nested="true">
    <div dojoType="dijit.layout.ContentPane" title="<iwebmvc:message argMessage="ui.issue.main.tabs.main" />" disabled="true" style="text-align:left">${fn:replace(requestScope[issue].description, "\\n", "<br/>")}</div>
    <div dojoType="dijit.layout.ContentPane" title="<iwebmvc:message argMessage="ui.issue.main.tabs.comments" />" disabled="true">
         <c:if test="${not empty requestScope[issue].commentsByDate}">
             <c:forEach items="${requestScope[issue].commentsByDate}" var="comment">
                 <div style="width:97%;padding:5px;text-align:left" class="overclear">
                     <div class="float_left" style="width:12%">
                         <img src="${comment.author.gravatar}" alt="" />
                     </div>
                     <div class="float_right" style="width:88%">
                         <div class="label">${comment.author.name}&nbsp;<iwebmvc:message argMessage="ui.issue.comment.commented" />&nbsp;<fmt:formatDate value="${comment.creationDate}" /></div>
                         <div>${comment.comment}</div>
                     </div>
                 </div>
                 <div style="margin-bottom:4px"><hr style="height:2px;" class="color_${sessionScope[sessionUser].theme}"/></div>
             </c:forEach>
        </c:if>
    </div>
    <div dojoType="dijit.layout.ContentPane" title="<iwebmvc:message argMessage="ui.issue.main.tabs.screenshots" />" style="text-align:left;padding: 5px" disabled="true">
        <table cellspacing="4">
            <tbody>
                <tr id="${fn:replace(requestScope[issue].alias, "-", "_")}Screenshots">
                    <td>&nbsp;</td>
                    <c:forEach items="${requestScope[issue].attachments.documents}" var="doc">
                        <c:if test="${doc.image}">
                            <td style="width:220px;border:1px solid gray;padding:5px;text-align:center">
                                <div><img src="<c:url value="/resource.iwebmvc?file=" /><iwebmvc:encrypt code="${doc.id}" />&width=200&height=200" alt="" onClick="lightbox('<c:url value="/resource.iwebmvc?file=" /><iwebmvc:encrypt code="${doc.id}" />')" /></div>
                                <div style="">${doc.identifier}</div>
                            </td>
                        </c:if>
                    </c:forEach>
                </tr>
            </tbody>
        </table>
    </div>
    <div dojoType="dijit.layout.ContentPane" title="<iwebmvc:message argMessage="ui.issue.main.tabs.file" />" style="text-align:left">
        <c:if test="${requestScope[issue].attachments != null}">
            <c:forEach items="${requestScope[issue].attachments.documents}" var="doc">
                <c:if test="${doc.text}">
                    <span style="display:inline-block;width:80px;margin-right:3px">
                        <div style="text-align:center"><img src="<c:url value="/resource.iwebmvc?file=/images/filetypes/" />${doc.extension}_${sessionScope[sessionUser].theme}.png" alt="${doc.identifier}" onClick="previewTextFile(byId('textPreviewerContainer'), '${doc.extension}', '<c:url value="/resource.iwebmvc?file=" /><iwebmvc:encrypt code="${doc.id}" />&escape=true')" /></div>
                        <div style="font-weight:bold;overflow:hidden;text-overflow:ellipsis;text-align:center;height:15px">${doc.identifier}</div>
                    </span>
                </c:if>
            </c:forEach>
        </c:if>
    </div>
    <div dojoType="dojox.layout.ContentPane" title="<iwebmvc:message argMessage="ui.issue.main.tabs.Links" />" style="text-align:left">
        <c:if test="${fn:length(requestScope[issue].links) > 0}">
            <c:forEach items="${requestScope[issue].links}" var="link">
                <div style="margin-bottom:5px">
                    <span><iwebmvc:message argMessage="ui.issue.link.this;${requestScope[issue].alias}" /></span>
                    <span>&nbsp;<iwebmvc:message argMessage="Link.${link.type}" />&nbsp;</span>
                    <span><iwebmvc:message argMessage="ui.issue.link.other" />&nbsp;<a href="javascript:openOrSelectTab('<iwebmvc:value encrypt="true" entity="${link.target}" path="id" />', '${link.target.alias}', 'issue')">${link.target.alias}</a>.</span>
                </div>
            </c:forEach>
        </c:if>
    </div>
</div>
